import java.io.*;
import java.util.Scanner;

public class demo5 {
    // 字节流：InputStream()
    public static void main(String[] args) throws IOException {
        InputStream inputStream=new FileInputStream("E:\\蠢阿伟\\test.txt");
        /*int n=inputStream.read();
        System.out.println((char)n);*/
        byte[] buffer=new byte[1024];
        while(true){
            int a=inputStream.read(buffer);
            if(a == -1){
                break;
            }
            for(int i=0;i<a;i++){
                System.out.print(buffer[i]);
            }
        }
        inputStream.close();

        System.out.println();

       // 更安全的方式：
        try(InputStream inputStream2=new FileInputStream("E:\\蠢阿伟\\test.txt")){
            byte[] buffer2=new byte[1024];
            int a=inputStream2.read(buffer);
            for(int i=0;i<a;i++){
                System.out.print(buffer[i]);
            }
        }catch (IOException e){
            e.printStackTrace();
        }
    }




}
